<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 在网页中引入axios的js文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script>
</head>
<body>
    <h1>05-axios的create()配置</h1>
    <button>加载</button>
    <script>
       

        // 获取按钮节点
        const btn = document.querySelector("button");

        // 使用axios的create（）来进行多个配置

        //1. 本地配置axios的配置
        const localAxios =  axios.create({
            method: "get",
            baseURL:"http://localhost:3000", 
        })
        //2. 配置httpbin的axios
        const httpbinAxios =  axios.create({
            method: "get",
            baseURL:"http://httpbin.org", 
        })

        // 绑定事件，执行ajax发送
        btn.onclick = async () => {
            // 使用本地的配置发送Ajax请求
            //const data = await localAxios({url:"/stu"});
            // 使用httbin的配置发送Ajax请求
            const data = await httpbinAxios({url:"/get"});
            console.log(data);
        }
        
    </script>

</body>
</html>